define(function(require){
	var $ = require("jquery");
	var justep = require("$UI/system/lib/justep");

	var Model = function(){
		this.callParent();
	};
	Model.prototype.getImageUrl = function(url) {
		return url?this.getParentModel().serverUrl+url:require.toUrl("$UI/CommunityOto/category/img/loading.jpg");
	};

	Model.prototype.infoDataCustomRefresh = function(event){
		
	
		if(event.source.count() < event.offset){
			return ;
		}
		this.comp("popOver1").show();
		var me = this;
//		this.getParentModel().serverUrl + 
		var url = this.getParentModel().serverUrl +"/ex_community/a/api/community/getSecondHand?callback=?";
		var page = event.offset/event.limit + 1;
		$.getJSON(
				url,
				{
//				    "category.id":this.catId,
				    'pageSize':event.limit,
				    'pageNo':page
				},
				function(data){
				console.log("infoDataCustomRefresh");
				console.log(data.data);
				    if(data && data.data){		
				    	event.source.loadData(data.data,true,null,event.offset,true);
				    	
				    }
				    me.loadDone = true;
				    me.comp("popOver1").hide();
				}
		);

	};
	
	Model.prototype.scrollView1PullUp = function(event){
	    if(this.loadDone){
	    	this.loadDone = false;
	    	this.comp("infoData").loadNextPageData();
	    }
		
	};
	
	Model.prototype.scrollView1PullDown = function(event){
	
		this.comp("infoData").refreshData();
		
	};

	Model.prototype.li1Click = function(event){
		var row = event.bindingContext.$object;
		justep.Shell.showPage("$UI/communityOto/category/categoryInfo.w?id="+row.val("id"));
	};

	return Model;
});